package spring.my.db.sharding.demo.exception;

import spring.my.db.sharding.demo.enums.BzStatus;

/**
 * spring 中有个 HttpStatusCodeException 可以参考
 */
public class BzException extends Exception {

    private int code;

    private String message;


    public BzException() {
        super();
    }

    public BzException(String message, int code) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public BzException(String message, Throwable cause) {
        super(message, cause);
        this.message = message;
    }

    public BzException(BzStatus status) {
        this.code = status.getCode();
        this.message = status.getMessage();
    }

    public BzException(String message) {
        super(message);
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
